-
-
Notifications
You must be signed in to change notification settings - Fork 669
Sync Array's & TypedArray's "includes" with spec #931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
(func $~lib/number/isNaN<f64> (; 62 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) | ||
local.get $0 | ||
local.get $0 | ||
f64.ne | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dcodeIO We definitely need tune inlining limits more better than binaryen's defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that's interesting. From looking over the inlining limits, this one seems as if it is smaller than flexibleInlineMaxSize = 20
and should be considered lightweight
(maybe it isn't?), so it should inline if optimizeLevel >= 3
and shrinkLevel == 0
. (see)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in -O3
it will be inlined but I guess even with shrinkLevel == 1
this should be possible. Only for shrinkLevel == 2 and 3
this unnecessary. -O3z
used by default so it pretty important provide nearly identical speed with -O3
with just slightly smaller size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw fan fact:
-O3
example with four isNaN
: https://webassembly.studio/?f=tsbtqbkt2ks
has size: 123 bytes
and with inlines
Same example but with -O3z
: https://webassembly.studio/?f=4jfqpshboq9
142 bytes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess sometimes, when code is inlined, even if it doesn't meet the inlining criteria introduced to avoid growing, it can be optimized much better further down the road than if it remained its own small function. The challenge here seems to be to detect that condition, which would have to estimate how much inlining a function that isn't considered worth inlining at first actually benefits from other passes after inlining. Quite a hard problem, that doesn't seem to be solvable by just tweaking the inlining options because this would then also inline stuff that doesn't actually benefit from other passes. As such, I think Binaryen is doing what it reasonably can do without either recompiling multiple times to observe the difference or go completely crazy trying to build an estimator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe one assumption we could apply in Os
is to ignore pushes to the stack involving function arguments, like the local.get
s in this specific example, expecting that these will usually blend in fine into the call site? I'm guessing, but that's somewhat testable. We'd then have a conservativeSize
and an eagerSize
when checking worthInlining
. Maybe. Perhaps.
Thanks! :) |
With
Array.p.include
we forgot one piece of puzzle.include
useObject.is
instead==
for element's comparison and in contrast withindexOf
. So we couldn't usereturn arr.indexOf() >= 0
for this.Before:
with PR: